package com.our123.cms.action.front;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.our123.cms.entity.main.CmsSite;
import com.our123.cms.web.CmsUtils;
import com.our123.cms.web.FrontUtils;
import com.our123.common.web.RequestUtils;

@Controller
public class AlonePageAct {
	public static final String TPLDIR_ALONE = "alone";

	@RequestMapping(value = "/alone/{tplName}.jsp", method = RequestMethod.GET)
	public String boutique(@PathVariable String tplName, HttpServletRequest request, HttpServletResponse response, ModelMap model) {
		CmsSite site = CmsUtils.getSite(request);
		model.putAll(RequestUtils.getQueryParams(request));
		FrontUtils.frontData(request, model, site);
		FrontUtils.frontPageData(request, model);
		Map<String, Object> param = RequestUtils.getQueryParams(request);
		model.addAllAttributes(param);
		if (tplName.indexOf("_") != -1) {
			tplName = tplName.substring(0, tplName.indexOf("_"));
		}
		return FrontUtils.getTplPath(site.getSolutionPath(), TPLDIR_ALONE, tplName);
	}
}
